package com.jili.controller;

import com.jili.entity.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: StudentExceptionController
 * Package com.jili.controller
 * Description:
 *
 * @Author: 廖继礼
 * @Create: 2025/3/8
 * @Version: v1.0
 */
@RequestMapping("/student")
@RestController
@Slf4j
public class StudentExceptionController {

    @PostMapping("/register")
    public Object registerStudent(@Validated @RequestBody Student student, BindingResult result) {
        if (result.hasErrors()) {
            Map map = new HashMap();
            map.put("code", 400);
            map.put("msg", "参数异常");
            return map;
        }
        return student;
    }
}
